<?php
	session_start();
	
	$host="localhost";
	$username="root";
	$password="";
	$database="cs4400_group17";

	mysql_connect($host,$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	
	$username = $_SESSION['userName'];
	$useremail = $_SESSION['userEmail'];
	
	$corkboardOwnEmail = $_GET['OwnerEmail'];
	
	print_r($corkboardOwnEmail);
	print_r($useremail);
	
	$sql = "SELECT * FROM userfollows WHERE Email = '$useremail' AND Followee = '$corkboardOwnEmail'";
	$result = mysql_query($sql);
	
	$count=mysql_num_rows($result);
			
			if($count < 1){
			    print "I came here";
				$sql = "INSERT INTO userfollows VALUES('$useremail','$corkboardOwnEmail')";
				mysql_query($sql);
			}
			else{
			    print "This is else";
				$sql = "DELETE FROM userfollows WHERE Email = '$useremail' AND Followee = '$corkboardOwnEmail'";
				mysql_query($sql);
			}

	
	header("location:home.php");
	
	
?>
